﻿using System;
using System.Collections.Generic;

using System.Text;
using MSL.DataBase.Core;
using System.Data.Common;
using System.Collections;
using System.Data;
using MSL.DataBase.Lib;

namespace MSL.DataBase
{
    /// <summary>
    /// 
    /// </summary>
    public static class DbHelper //: DbBase
    {
        private static IDbHelper dbHelper = DbFactory.GetHelper(DBConfig.ConnString);

        /// <summary>
        /// DbFactory实例
        /// </summary>
        //public static DbProviderFactory Factory
        //{
        //    get
        //    {
        //        if (factory == null)
        //        {
        //            factory = DbFactory.GetHelper(dataBaseType, connString);
        //        }
        //        return factory;
        //    }
        //}

        #region else methods
        /// <summary>
        ///  获得Sql字符串相加符号
        /// </summary>
        /// <param name="values">参数值</param>
        /// <returns>字符加</returns>
        public static string PlusSign(params string[] values)
        {
            return dbHelper.PlusSign(values);
        }
        /// <summary>
        /// 打开数据库链接
        /// </summary>
        public static void Open()
        {
            dbHelper.Open();
        }
        /// <summary>
        /// 关闭数据库链接
        /// </summary>
        public static void Close()
        {
            dbHelper.Close();
        }
        /// <summary>
        /// 打开数据库链接
        /// </summary>
        public static void Open(string connString)
        {
            DbFactory.GetHelper(connString).Open();
        }
        /// <summary>
        /// 关闭数据库链接
        /// </summary>
        public static void Close(string connString)
        {
            DbFactory.GetHelper(connString).Close();
        }
        #endregion

        #region ExecReader

        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string commandText)
        {
            return dbHelper.ExecReader(commandText, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string connString, string commandText)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, false);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string commandText, bool isProc)
        {
            return dbHelper.ExecReader(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string connString, string commandText, bool isProc)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, isProc);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string commandText, DbParameter[] parameters)
        {
            return dbHelper.ExecReader(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string connString, string commandText, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, false, parameters);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string commandText, bool isProc, DbParameter[] parameters)
        {
            return dbHelper.ExecReader(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string connString, string commandText, bool isProc, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, isProc, parameters);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string commandText, Hashtable parameters)
        {
            return dbHelper.ExecReader(commandText, false, parameters);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string connString, string commandText, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, false, parameters);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string commandText, bool isProc, Hashtable parameters)
        {
            return dbHelper.ExecReader(commandText, isProc, parameters);
        }
        /// <summary>
        /// 获得DbDataReader
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static DbDataReader ExecReader(string connString, string commandText, bool isProc, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, isProc, parameters);
        }
        #endregion

        #region ExecSql

        /// <summary>
        /// 执行sql语句
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static int ExecSql(string commandText)
        {
            return dbHelper.ExecSql(commandText, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static int ExecSql(string connString, string commandText)
        {
            return DbFactory.GetHelper(connString).ExecSql(commandText, false);
        }
        /// <summary>
        /// 执行sql语句
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static int ExecSql(string commandText, bool isProc)
        {
            return dbHelper.ExecSql(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <returns></returns>
        public static int ExecSql(string connString, string commandText, bool isProc)
        {
            return DbFactory.GetHelper(connString).ExecSql(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static int ExecSql(string commandText, DbParameter[] parameters)
        {
            return dbHelper.ExecSql(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static int ExecSql(string connString, string commandText, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).ExecSql(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static int ExecSql(string commandText, bool isProc, DbParameter[] parameters)
        {
            return dbHelper.ExecSql(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static int ExecSql(string connString, string commandText, bool isProc, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).ExecSql(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static int ExecSql(string commandText, Hashtable parameters)
        {
            return dbHelper.ExecSql(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static int ExecSql(string connString, string commandText, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).ExecSql(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static int ExecSql(string commandText, bool isProc, Hashtable parameters)
        {
            return dbHelper.ExecSql(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static int ExecSql(string connString, string commandText, bool isProc, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).ExecSql(commandText, isProc, parameters);
        }
        /// <summary>
        /// 执行多条SQL（Insert/Delete/Update）
        /// </summary>
        /// <param name="listCmdTextAndParams"></param>
        /// <returns></returns>
        public static int ExecSql(List<SqlCmdTextAndParams> listCmdTextAndParams)
        {
            return dbHelper.ExecSql(listCmdTextAndParams);
        }
        /// <summary>
        /// 执行多条SQL（Insert/Delete/Update）
        /// </summary>
        /// <param name="listCmdTextAndParams"></param>
        /// <returns></returns>
        public static int ExecSql(string connString, List<SqlCmdTextAndParams> listCmdTextAndParams)
        {
            return DbFactory.GetHelper(connString).ExecSql(listCmdTextAndParams);
        }
        #endregion

        #region ExecScalar

        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static object ExecScalar(string commandText)
        {
            return dbHelper.ExecScalar(commandText, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static object ExecScalar(string connString, string commandText)
        {
            return DbFactory.GetHelper(connString).ExecScalar(commandText, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static object ExecScalar(string commandText, bool isProc)
        {
            return dbHelper.ExecScalar(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <returns></returns>
        public static object ExecScalar(string connString, string commandText, bool isProc)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static object ExecScalar(string commandText, DbParameter[] parameters)
        {
            return dbHelper.ExecScalar(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static object ExecScalar(string connString, string commandText, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static object ExecScalar(string commandText, bool isProc, DbParameter[] parameters)
        {
            return dbHelper.ExecScalar(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static object ExecScalar(string connString, string commandText, bool isProc, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static object ExecScalar(string commandText, Hashtable parameters)
        {
            return dbHelper.ExecScalar(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static object ExecScalar(string connString, string commandText, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static object ExecScalar(string commandText, bool isProc, Hashtable parameters)
        {
            return dbHelper.ExecScalar(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static object ExecScalar(string connString, string commandText, bool isProc, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).ExecReader(commandText, isProc, parameters);
        }
        #endregion

        #region Query(DataTable)
        /// <summary>
        /// 获得DataTable
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DataTable Query(string commandText)
        {
            return dbHelper.Query(commandText, false);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <returns></returns>
        public static DataTable Query(string connString, string commandText)
        {
            return DbFactory.GetHelper(connString).Query(commandText, false);
        }
        /// <summary>
        /// 获得DataTable
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static DataTable Query(string commandText, bool isProc)
        {
            return dbHelper.Query(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <returns></returns>
        public static DataTable Query(string connString, string commandText, bool isProc)
        {
            return DbFactory.GetHelper(connString).Query(commandText, isProc);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable Query(string commandText, DbParameter[] parameters)
        {
            return dbHelper.Query(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable Query(string connString, string commandText, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).Query(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable Query(string commandText, bool isProc, DbParameter[] parameters)
        {
            return dbHelper.Query(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable Query(string connString, string commandText, bool isProc, DbParameter[] parameters)
        {
            return DbFactory.GetHelper(connString).Query(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable Query(string commandText, Hashtable parameters)
        {
            return dbHelper.Query(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static DataTable Query(string connString, string commandText, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).Query(commandText, false, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataTable Query(string commandText, bool isProc, Hashtable parameters)
        {
            return dbHelper.Query(commandText, isProc, parameters);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static DataTable Query(string connString, string commandText, bool isProc, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).Query(commandText, isProc, parameters);
        }
        #endregion

        #region Query(DataSet)

        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static DataSet Query(string connString, string commandText, string srcTable)
        {
            return DbFactory.GetHelper(connString).Query(commandText, false, srcTable);
        }
        /// <summary>
        /// 获得DataSet
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否存储过程</param>
        /// <returns></returns>
        public static DataSet Query(string commandText, bool isProc, string srcTable)
        {
            return dbHelper.Query(commandText, isProc, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <returns></returns>
        public static DataSet Query(string connString, string commandText, bool isProc, string srcTable)
        {
            return DbFactory.GetHelper(connString).Query(commandText, isProc, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataSet Query(string commandText, DbParameter[] parameters, string srcTable)
        {
            return dbHelper.Query(commandText, false, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataSet Query(string connString, string commandText, DbParameter[] parameters, string srcTable)
        {
            return DbFactory.GetHelper(connString).Query(commandText, false, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataSet Query(string commandText, bool isProc, DbParameter[] parameters, string srcTable)
        {
            return dbHelper.Query(commandText, isProc, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataSet Query(string connString, string commandText, bool isProc, DbParameter[] parameters, string srcTable)
        {
            return DbFactory.GetHelper(connString).Query(commandText, isProc, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataSet Query(string commandText, Hashtable parameters, string srcTable)
        {
            return Query(commandText, false, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <param name="srcTable">表名</param>
        /// <returns></returns>
        public static DataSet Query(string connString, string commandText, Hashtable parameters, string srcTable)
        {
            return DbFactory.GetHelper(connString).Query(commandText, false, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static DataSet Query(string commandText, bool isProc, Hashtable parameters, string srcTable)
        {
            return Query(commandText, isProc, parameters, srcTable);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否为存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static DataSet Query(string connString, string commandText, bool isProc, Hashtable parameters, string srcTable)
        {
            return DbFactory.GetHelper(connString).Query(commandText, isProc, parameters, srcTable);
        }
        #endregion

        #region Existis
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static bool TableExists(string tableName)
        {
            return dbHelper.TableExists(tableName);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static bool TableExists(string connString, string tableName)
        {
            return DbFactory.GetHelper(connString).TableExists(tableName);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static bool Exists(string commandText)
        {
            return dbHelper.Exists(commandText);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="connString">链接</param>
        /// <param name="commandText">sql语句</param>
        /// <returns></returns>
        public static bool Exists(string connString, string commandText)
        {
            return DbFactory.GetHelper(connString).Exists(commandText);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static bool Exists(string commandText, Hashtable parameters)
        {
            return dbHelper.Exists(commandText, parameters);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="connString">链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static bool Exists(string connString, string commandText, Hashtable parameters)
        {
            return DbFactory.GetHelper(connString).Exists(commandText, parameters);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否是存储过程</param>
        /// <returns></returns>
        public static bool Exists(string commandText, bool isProc)
        {
            return dbHelper.Exists(commandText, isProc);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否是存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static bool Exists(string commandText, Hashtable parameters, bool isProc)
        {
            return dbHelper.Exists(commandText, parameters, isProc);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否是存储过程</param>
        /// <returns></returns>
        public static bool Exists(string connString, string commandText, bool isProc)
        {
            return DbFactory.GetHelper(connString).Exists(commandText, isProc);
        }
        /// <summary>
        /// 记录是否存在
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="isProc">是否是存储过程</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static bool Exists(string connString, string commandText, Hashtable parameters, bool isProc)
        {
            return DbFactory.GetHelper(connString).Exists(commandText, parameters, isProc);
        }
        #endregion

        #region Query

        /// <summary>
        /// 带分页功能的选择[多条件查询,选择所有时只需把PageIndex/PageSize设置为0]
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="primaryKey">主键 可以为空</param>
        /// <param name="showFields">显示字段</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">每页数量[为0时默认选择所有]</param>
        /// <param name="where">查询条件</param>
        /// <param name="sortBy">排序</param>
        /// <param name="groupBy">分组</param>
        /// <param name="rowCount">返回行数</param>
        /// <returns></returns>
        public static DataTable Query(string tableName, string primaryKey, string showFields, int pageIndex, int pageSize, string where, string sortBy, string groupBy, out int rowCount)
        {
            return dbHelper.Query(tableName, primaryKey, showFields, pageIndex, pageSize, where, sortBy, groupBy, out rowCount);
        }
        /// <summary>
        /// 带分页功能的选择[多条件查询,选择所有时只需把PageIndex/PageSize设置为0]
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="tableName">表名</param>
        /// <param name="primaryKey">主键 可以为空</param>
        /// <param name="showFields">显示字段</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">每页数量[为0时默认选择所有]</param>
        /// <param name="where">查询条件</param>
        /// <param name="sortBy">排序</param>
        /// <param name="groupBy">分组</param>
        /// <param name="rowCount">返回行数</param>
        /// <returns></returns>
        public static DataTable Query(string connString, string tableName, string primaryKey, string showFields, int pageIndex, int pageSize, string where, string sortBy, string groupBy, out int rowCount)
        {
            return DbFactory.GetHelper(connString).Query(tableName, primaryKey, showFields, pageIndex, pageSize, where, sortBy, groupBy, out rowCount);
        }

        #endregion

        #region Bulk Operate
        /// <summary>
        /// 大批量数据插入
        /// </summary>
        /// <param name="table">数据表</param>
        public static void BulkInsert(DataTable table)
        {
            dbHelper.BulkInsert(table);
        }
        /// <summary>
        /// 大批量数据插入
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="table">数据表</param>
        public static void BulkInsert(string connString, DataTable table)
        {
            DbFactory.GetHelper(connString).BulkInsert(table);
        }
        /// <summary>
        /// 批量更新数据
        /// </summary>
        /// <param name="table">数据表</param>
        public static void BatchUpdate(DataTable table)
        {
            dbHelper.BatchUpdate(table);
        }
        /// <summary>
        /// 批量更新数据
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="table">数据表</param>
        public static void BatchUpdate(string connString, DataTable table)
        {
            DbFactory.GetHelper(connString).BatchUpdate(table);
        }
        /// <summary>
        /// 分批次批量删除数据
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <param name="batchSize">每批次更新记录行数</param>
        /// <param name="interval">批次执行间隔(秒)</param>
        public static void BatchDelete(string sql, int batchSize = 1000, int interval = 1)
        {
            dbHelper.BatchDelete(sql, batchSize, interval);
        }
        /// <summary>
        /// 分批次批量删除数据
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="sql">SQL语句</param>
        /// <param name="batchSize">每批次更新记录行数</param>
        /// <param name="interval">批次执行间隔(秒)</param>
        public static void BatchDelete(string connString, string sql, int batchSize = 1000, int interval = 1)
        {
            DbFactory.GetHelper(connString).BatchDelete(sql, batchSize, interval);
        }
        /// <summary>
        /// 分批次批量更新数据
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <param name="batchSize">每批次更新记录行数</param>
        /// <param name="interval">批次执行间隔(秒)</param>
        public static void BatchUpdate(string sql, int batchSize = 1000, int interval = 1)
        {
            dbHelper.BatchUpdate(sql, batchSize, interval);
        }
        /// <summary>
        /// 分批次批量更新数据
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="sql">SQL语句</param>
        /// <param name="batchSize">每批次更新记录行数</param>
        /// <param name="interval">批次执行间隔(秒)</param>
        public static void BatchUpdate(string connString, string sql, int batchSize = 1000, int interval = 1)
        {
            DbFactory.GetHelper(connString).BatchUpdate(sql, batchSize, interval);
        }
        #endregion

        #region db manage

        /// <summary>
        /// 还原数据库
        /// </summary>
        /// <param name="dbName">数据库名</param>
        /// <param name="backfile">备份文件</param>
        /// <returns>还原成功与否提示</returns>
        public static bool RestoreDatabase(string dbName, string backfile)
        {
            return dbHelper.RestoreDatabase(dbName, backfile);
        }
        /// <summary>
        /// 还原数据库
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="dbName">数据库名</param>
        /// <param name="backfile">备份文件</param>
        /// <returns>还原成功与否提示</returns>
        public static bool RestoreDatabase(string connString, string dbName, string backfile)
        {
            return DbFactory.GetHelper(connString).RestoreDatabase(dbName, backfile);
        }
        /// <summary>
        /// 新建数据库
        /// </summary>
        /// <param name="databaseName">数据库名</param>
        public static bool CreateDataBase(string databaseName)
        {
            return dbHelper.CreateDataBase(databaseName);
        }
        /// <summary>
        /// 新建数据库
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="databaseName">数据库名</param>
        public static bool CreateDataBase(string connString, string databaseName)
        {
            return DbFactory.GetHelper(connString).CreateDataBase(databaseName);
        }
        /// <summary>
        /// 删除数据库
        /// </summary>
        /// <param name="databaseName">数据库名</param>
        public static bool DropDataBase(string databaseName)
        {
            return dbHelper.DropDataBase(databaseName);
        }
        /// <summary>
        /// 删除数据库
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="databaseName">数据库名</param>
        public static bool DropDataBase(string connString, string databaseName)
        {
            return DbFactory.GetHelper(connString).DropDataBase(databaseName);
        }
        /// </summary>
        /// 备份数据库
        /// </summary>
        /// <param name="dbName">数据库名</param>
        /// <param name="dbFileName">备份文件</param>
        /// <returns>是否备份成功</returns>
        public static bool BackDataBase(string dbName, string dbFileName)
        {
            return dbHelper.BackDataBase(dbName, dbFileName);
        }
        /// </summary>
        /// 备份数据库
        /// </summary>
        /// <param name="connString">数据库链接</param>
        /// <param name="dbName">数据库名</param>
        /// <param name="dbFileName">备份文件</param>
        /// <returns>是否备份成功</returns>
        public static bool BackDataBase(string connString, string dbName, string dbFileName)
        {
            return DbFactory.GetHelper(connString).BackDataBase(dbName, dbFileName);
        }
        #endregion
    }
}
